package com.engineering.elink.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import springfox.documentation.annotations.ApiIgnore;

import com.engineering.elink.common.DictConstant;
import com.engineering.elink.common.ErrorType;
import com.engineering.elink.service.JobService;
import com.engineering.elink.service.VideoSubTitleService;
import com.engineering.elink.util.ResJsonUtil;

@RestController
@CrossOrigin
@RequestMapping("/api/subtitle")
@Api(value="视频字幕相关接口")
public class VideoSubTitleController {
	
	@Autowired
	private JobService jobService;
	
	@Autowired
	private VideoSubTitleService videoSubTitleService;
	
	@RequestMapping(value = "/getSubtitleType", method = RequestMethod.GET)
	@ApiOperation(value = "获取字幕类型")
	public Map<String, Object> getSubtitleType() {
		
		return ResJsonUtil.getMap(ErrorType.SUCCESS,jobService.getDictCategoryByCode(DictConstant.VIDEO_SUBTITLE,null));
	}
	
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ApiOperation(value="保存视频字幕")
	@ApiIgnore
	public Map<String,Object> add(
			@ApiParam(value="字幕JSON字符串(示例：[{\"videoId\":0,\"type\":\"1\",\"address\":\"1\"},{\"videoId\":0,\"type\":\"1\",\"address\":\"1\"}])",required=true)
			@RequestParam(value="jsonStr",required=true) String jsonStr){
		return videoSubTitleService.add(jsonStr);
	}
	
}
